﻿@using System.Linq
@using Microsoft.AspNetCore.Components.Forms
@inherits FormComponent<int>
@if (Visible)
{
    <div @ref="@Element" @attributes="Attributes" class="@GetCssClass()" id="@GetId()">
        @if (!ReadOnly)
        {
            <a href="javascript:void(0)" class="rz-rating-cancel" tabindex="@(Disabled ? "-1" : $"{TabIndex}")" @onclick="@(args => SetValue(0))" @onkeypress="@(async args => { if (args.Code == "Space") { await SetValue(0); } })">
                <span class="rz-rating-icon rzi rzi-ban"></span>
            </a>
        }
        @foreach (var index in Enumerable.Range(1, Stars))
        {

            @if (index <= Value)
            {
                <a href="javascript:void(0)" tabindex="@(Disabled ? "-1" : $"{TabIndex}")" @onclick="@(args => SetValue(index))" @onkeypress="@(async args => { if (args.Code == "Space") { await SetValue(index); } })">
                    <span class="rz-rating-icon rzi rzi-star"></span>
                </a>
            }
            else
            {
                <a href="javascript:void(0)" tabindex="@(Disabled ? "-1" : $"{TabIndex}")" @onclick="@(args => SetValue(index))" @onkeypress="@(async args => { if (args.Code == "Space") { await SetValue(index); } })">
                    <span class="rz-rating-icon rzi rzi-star-o"></span>
                </a>
            }
        }
    </div>
}
